package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.math.BigDecimal;
import java.util.Map;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import org.come.bean.ConfigureBean;
import org.come.model.Configure;
import org.come.until.UserMessUntil;

import com.tool.btn.CommonBtn;
import com.tool.tcpimg.UIUtils;
import com.tool.time.Limit;
import com.tool.time.TimeLimit;
import com.tool.time.TimerUtil;
import com.updateNew.MyIsif;



/**
 * 月卡面板
 *
 * @author zeng
 */
public class MonthlyCardJpanel extends JPanel {

    /**
     * 剩余天数
     */
    private JLabel dayNum;

    /**
     * 仙玉
     */
    private JLabel xy;

    /**
     * 每日奖励
     */
    private JLabel mrjl;
    /**
     * 每日奖励
     */
    private JLabel mrjl1;

    public String str = "";
    /**
     * 购买月卡按钮getMonthBtn<br>
     * 购买周卡按钮getMonthBtn<br>
     * 领取奖励按钮getMonthBtn<br>
     */
    private CommonBtn getMonthBtn, getWeekBtn, receiveAwardBtn,receiveAwardBtn1,receiveAwardBtn2;

    public MonthlyCardJpanel() {
        ConfigureBean allConfigure = UserMessUntil.getConfigureBean();
        Map<BigDecimal, Configure> item = allConfigure.getAllConfigure();
        Configure configure = item.get(new BigDecimal(5));
        str = "<html>" + configure.getZqsld() + "</html>";
        // TODO Auto-generated constructor stub
        this.setPreferredSize(new Dimension(618, 450));//修改
        this.setLayout(null);
        this.setOpaque(false);
        getDayNum();
        getReceiveAwardBtn();
        getReceiveAwardBtn1();
        getReceiveAwardBtn2();

        changeTime();
    }
    private ImageIcon iconBack = new ImageIcon("inkImg/hongmu/月卡权益介绍.png");

    @Override

    public void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponents(g);
        // TODO Auto-generated constructor stub
        g.drawImage(iconBack.getImage(), 163, -10, 618, 450, this);//修改
        receiveAwardBtn.setBounds(225, 400 + 40, 103, 31);
        receiveAwardBtn1.setBounds(422, 400 + 40, 103, 31);
        receiveAwardBtn2.setBounds(622, 400 + 40, 103, 31);
    }

    /**
     * 展示剩余时间
     */
    public void changeTime() {
        Limit limit = TimeLimit.getLimits().getLimit("VIP");
        if (limit != null) {
            int residueDay = TimerUtil.residueDay(limit.getTime());
            if (residueDay >= 0) {
                dayNum.setText("月卡剩余天数："+residueDay+"天");
                dayNum.setBounds(583, 5, 350, 16);
                return;
            }
        }
        dayNum.setText("--");
        dayNum.setBounds(583, 5, 350, 16);
    }

    public JLabel getDayNum() {
        if (dayNum == null) {
            dayNum = new JLabel();
            dayNum.setFont(UIUtils.TEXT_FONT3);
            dayNum.setForeground(Color.black);
            dayNum.setBounds(583, 5, 350, 16);
            dayNum.setOpaque(false);
            this.add(dayNum);
        }
        return dayNum;
    }

    public void setDayNum(JLabel dayNum) {
        this.dayNum = dayNum;
    }

    public ImageIcon getIconBack() {
        return iconBack;
    }

    public void setIconBack(ImageIcon iconBack) {
        this.iconBack = iconBack;
    }

    public CommonBtn getReceiveAwardBtn() {
        if (receiveAwardBtn == null) {
            receiveAwardBtn = new CommonBtn("inkImg/Client/修复耐久按钮.png", 1, "领取奖励", 20, this, null);
            receiveAwardBtn.setBounds(374, 410, 103, 31);
            this.add(receiveAwardBtn);
        }
        return receiveAwardBtn;
    }
    public CommonBtn getReceiveAwardBtn1() {
        if (receiveAwardBtn1 == null) {
            receiveAwardBtn1 = new CommonBtn("inkImg/Client/修复耐久按钮.png", 1, "领取奖励", 9920, this, null);
            receiveAwardBtn1.setBounds(374, 410, 103, 31);
            this.add(receiveAwardBtn1);
        }
        return receiveAwardBtn;
    }
    public CommonBtn getReceiveAwardBtn2() {
        if (receiveAwardBtn2 == null) {
            receiveAwardBtn2 = new CommonBtn("inkImg/Client/修复耐久按钮.png", 1, "领取奖励", 9921, this, null);
            receiveAwardBtn2.setBounds(374, 410, 103, 31);
            this.add(receiveAwardBtn2);
        }
        return receiveAwardBtn2;
    }

    public void setReceiveAwardBtn(CommonBtn receiveAwardBtn) {
        this.receiveAwardBtn = receiveAwardBtn;
    }

    public void setReceiveAwardBtn1(CommonBtn receiveAwardBtn1) {
        this.receiveAwardBtn1 = receiveAwardBtn1;
    }

    public void setReceiveAwardBtn2(CommonBtn receiveAwardBtn2) {
        this.receiveAwardBtn2 = receiveAwardBtn2;
    }
}
